package org.code.clientemovil;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.Spinner;

public class Opciones extends Activity{
	private RadioButton menu, carta, especialidad;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.opciones);

		ImageView logo = (ImageView)findViewById(R.id.imageView2);
		logo.setOnClickListener(new View.OnClickListener() {
			public void onClick(View arg0)
			{
				Intent intent = new Intent(Opciones.this, MainActivity.class);
				startActivity(intent);
			}
		});

		Spinner sp = (Spinner) findViewById(R.id.spinner1);
		ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
				R.array.itemsSpinner,android.R.layout.simple_spinner_item);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		sp.setAdapter(adapter);
		final Button buscar = (Button)findViewById(R.id.button1);

		buscar.setOnClickListener(new View.OnClickListener() {
			public void onClick(View arg0)
			{
				menu = (RadioButton)findViewById(R.id.radioButton1);
				carta = (RadioButton)findViewById(R.id.radioButton2); 
				especialidad = (RadioButton)findViewById(R.id.radioButton3);
				//Creamos el Intent
				Intent intent = new Intent(Opciones.this, BuscarRestaurantes.class);
				if(menu.isChecked()==true){
					Bundle b = new Bundle();
					b.putString("Filtro", "menu");
					intent.putExtras(b);
				}
				else if(carta.isChecked()==true){
					Bundle b = new Bundle();
					b.putString("Filtro", "carta");
					intent.putExtras(b);		        	
				}
				else if(especialidad.isChecked()==true){
					Spinner sp = (Spinner)findViewById(R.id.spinner1);
					sp.getSelectedItem();

					Bundle b = new Bundle();
					b.putString("Filtro", sp.getSelectedItem().toString());
					intent.putExtras(b);
				}
				startActivity(intent);
			}
		});
	}
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}
}
